<template>
  <select-modal ref="selectModal" title="选择{{title}}" :api="api" :columns="columns" :search-config="searchConfig" :multiple="multiple" @selectRow="selectRow" />
</template>
<script>
  import SelectModal from "@ultra/share/components/SelectModal/SelectModal.vue";

  export default {
    name: "{{name}}",
    components: { SelectModal },
    props: {
      multiple: {
        type: String,
        default() {
          return "multiple";
        },
      },
      api: {
        type: Function,
        default: {{api}}
      },
      options: {
        type: Object,
        default() {
          return {};
        },
      },
    },
    data() {
      return {
        searchConfig: {
          formItemConfig: [{ label: "产品专用号", prop: "projectMaterialCode" }],
        },
        columns: [
          { type: "index", label: "序号", width: "60px" },
          { label: "产品专用号", prop: "projectMaterialCode" },
          { label: "规格", prop: "projectMaterialName" },
          { label: "版本号", prop: "version" },
          { label: "创建时间", prop: "createTime" },
        ],
      };
    },
    methods: {
      show() {
        const params = {...this.options};
        Reflect.ownKeys(params).forEach((key) => {
          this.$refs.selectModal.searchParams[key] = params[key];
        });
        this.$refs.selectModal.backUpParams();
        this.$refs.selectModal.show();
      },
      hide() {
        this.$refs.selectModal.hide();
      },
      selectRow(e) {
        this.$emit("selectRow", e);
      },
    },
  };
</script>
